package com.xianzhiOA.websocket;

import javax.websocket.Session;
import java.io.IOException;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2017/5/11.
 */
public class SocketMsgUtil{
    public static void msgGo(String msg, Long selfId){
        Map<Long,Session> map = MsgSocket.sessionMap;
        Set<Long> mapKey = map.keySet();
        System.out.println("进入工具类"+mapKey.size());
        for (Long key : mapKey) {
            if(!key.equals(selfId)){
                Session otherSession = map.get(key);
                try {
                    otherSession.getBasicRemote().sendText(msg);
                    System.out.println("消息发送给："+otherSession.getId());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
